---
title: "Simple Storage"
description: "REST endpoints for App key-value storage under /api/sdk/simple-storage"
---

## Overview

The Simple Storage API provides a localStorage-like interface for MentraOS Apps to store and retrieve key-value data. Data is isolated by user email (`:email`) and the authenticated `packageName` from the Authorization header.

<Warning>
All endpoints require SDK authentication with:
<br />
<code>Authorization: Bearer &lt;packageName&gt;:&lt;apiKey&gt;</code>
</Warning>

- Base path: `/api/sdk/simple-storage`
- Scope: Each storage namespace is unique per `(email, packageName)`
- Values: All values are strings (serialize complex data as JSON)

---

## Get Complete Storage

Retrieve the entire key/value object for a user and authenticated package.

### Endpoint

<CodeGroup>
```bash Production
GET https://api.mentra.glass/api/sdk/simple-storage/:email
```

```bash Development
GET https://devapi.mentra.glass/api/sdk/simple-storage/:email
```

```bash Local
GET http://localhost:8002/api/sdk/simple-storage/:email
```
</CodeGroup>

### Path Parameters
- `email` (string, required): User's email identifier

### Headers
```
Authorization: Bearer <packageName>:<apiKey>
```

### Response (200)
```json
{
  "success": true,
  "data": {
    "key1": "value1",
    "key2": "value2"
  }
}
```

---

## Upsert Multiple Items

Create or update multiple key/value pairs in one request.

### Endpoint

<CodeGroup>
```bash Production
PUT https://api.mentra.glass/api/sdk/simple-storage/:email
```

```bash Development
PUT https://devapi.mentra.glass/api/sdk/simple-storage/:email
```

```bash Local
PUT http://localhost:8002/api/sdk/simple-storage/:email
```
</CodeGroup>

### Path Parameters
- `email` (string, required)

### Headers
```
Authorization: Bearer <packageName>:<apiKey>
Content-Type: application/json
```

### Request Body
```json
{
  "data": {
    "setting1": "value1",
    "setting2": "value2"
  }
}
```

- All values must be strings
- Upsert/merge semantics (non-destructive). To clear all data, use DELETE below.

### Response (200)
```json
{
  "success": true,
  "message": "Storage updated"
}
```

---

## Clear Storage

Remove all key/value pairs for the user and authenticated package.

### Endpoint

<CodeGroup>
```bash Production
DELETE https://api.mentra.glass/api/sdk/simple-storage/:email
```

```bash Development
DELETE https://devapi.mentra.glass/api/sdk/simple-storage/:email
```

```bash Local
DELETE http://localhost:8002/api/sdk/simple-storage/:email
```
</CodeGroup>

### Path Parameters
- `email` (string, required)

### Headers
```
Authorization: Bearer <packageName>:<apiKey>
```

### Response (200)
```json
{
  "success": true,
  "message": "Storage cleared"
}
```

---

## Get Single Key

Retrieve a single value by key.

### Endpoint

<CodeGroup>
```bash Production
GET https://api.mentra.glass/api/sdk/simple-storage/:email/:key
```

```bash Development
GET https://devapi.mentra.glass/api/sdk/simple-storage/:email/:key
```

```bash Local
GET http://localhost:8002/api/sdk/simple-storage/:email/:key
```
</CodeGroup>

### Path Parameters
- `email` (string, required)
- `key` (string, required)

### Headers
```
Authorization: Bearer <packageName>:<apiKey>
```

### Response (200)
```json
{
  "success": true,
  "data": { "value": "stored_value" }
}
```

### Not Found (404)
```json
{
  "success": false,
  "message": "Key not found"
}
```

---

## Set Single Key

Create or update a single key.

### Endpoint

<CodeGroup>
```bash Production
PUT https://api.mentra.glass/api/sdk/simple-storage/:email/:key
```

```bash Development
PUT https://devapi.mentra.glass/api/sdk/simple-storage/:email/:key
```

```bash Local
PUT http://localhost:8002/api/sdk/simple-storage/:email/:key
```
</CodeGroup>

### Path Parameters
- `email` (string, required)
- `key` (string, required)

### Headers
```
Authorization: Bearer <packageName>:<apiKey>
Content-Type: application/json
```

### Request Body
```json
{
  "value": "new_value"
}
```

### Response (200)
```json
{
  "success": true,
  "message": "Key \"<key>\" set"
}
```

---

## Delete Single Key

Delete a single key.

### Endpoint

<CodeGroup>
```bash Production
DELETE https://api.mentra.glass/api/sdk/simple-storage/:email/:key
```

```bash Development
DELETE https://devapi.mentra.glass/api/sdk/simple-storage/:email/:key
```

```bash Local
DELETE http://localhost:8002/api/sdk/simple-storage/:email/:key
```
</CodeGroup>

### Path Parameters
- `email` (string, required)
- `key` (string, required)

### Headers
```
Authorization: Bearer <packageName>:<apiKey>
```

### Response (200)
```json
{
  "success": true,
  "message": "Key \"<key>\" deleted"
}
```

---

## Error Codes

| Code | Description |
|------|-------------|
| 400  | Missing or invalid parameters |
| 401  | Unauthorized (missing/invalid Authorization) |
| 404  | Storage or key not found |
| 500  | Internal server error |

---

## Data Model

Storage documents are scoped per `(email, packageName)`.

```json
{
  "_id": "ObjectId",
  "email": "user@example.com",
  "packageName": "com.example.app",
  "data": {
    "key1": "value1",
    "key2": "value2"
  },
  "createdAt": "2023-...",
  "updatedAt": "2023-..."
}
```

<Note>
- The `data` field is a record of string keys to string values.
- For complex data, JSON-serialize the value before storing.
</Note>

---

## Notes

- Prefer bulk updates with PUT `/:email` when setting multiple keys at once.
- The SDK provides convenience methods (`get`, `set`, `delete`, `clear`, `setMultiple`) that call these endpoints.
- Keys, size, and existence checks can be derived client-side by fetching the full dataset when needed.